package com.hzhc.controller.baseinfo;

import cn.hutool.core.util.StrUtil;
import com.hzhc.common.BaseController;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.CntrStockPlanService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.vo.DeclareCarVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: BayAutoCalcController
 * @Description:贝位自动计算
 * @version 1.0
 * @author: duanhm
 * @Date: 2021/09/13 15:41:21
 *
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/bayAutoCalc")
public class BayAutoCalcController extends BaseController {

	private final CntrStockPlanService cntrStockPlanService;

	/**
	 * 计算计划贝位
	 *
	 * @param vo
	 * @return
	 */
	@PostMapping("/getJHbayCalc")
	@ResponseBody
	public ResultUtil<String> getJHbayCalc(@RequestBody DeclareCarVo vo) {
		String jhbw = cntrStockPlanService.getBayCalc(vo);
		Map<String, Object> map = new HashMap<String, Object>();
		if (StrUtil.isBlank(jhbw)) {
			map.put("success", false);
			return  ResultUtil.fail();
		} else {
			map.put("success", true);
			map.put("data", jhbw);
			return  ResultUtil.build(jhbw, ResultUtilCodeEnum.SUCCESS);
		}
	}

}
